package com.chaodroid.flyui.view.viewpager.loop;

import android.support.v4.view.ViewPager;

/**
 * Created by CHEN on 2017/12/20.
 */

public class LoopPageChangeListener implements ViewPager.OnPageChangeListener {

    private ViewPager.OnPageChangeListener mListener;
    private int mItemCount;

    public LoopPageChangeListener(int itemCount,ViewPager.OnPageChangeListener listener) {
        mItemCount = itemCount;
        mListener = listener;
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        mListener.onPageScrolled(position % mItemCount, positionOffset, positionOffsetPixels);
    }

    @Override
    public void onPageSelected(int position) {
        mListener.onPageSelected(position % mItemCount);
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}
